/**
 * @file    drv_i2c_soft.h
 * @author  yhy
 * @brief   芯必达IM94x系列芯片, 软件模拟I2C抽象层
 * @version 1.00
 * @date    2025-07-16
 *
 * @copyright Copyright (c) 2025
 *
 * @details
 * Change Logs:
 * Date           Author       Notes
 * 2025-07-16     yhy          the first version V1.00
 *
 */
#ifndef __DRV_I2C_SOFT_H__
#define __DRV_I2C_SOFT_H__

#include "common_config.h"

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

#define I2C_SOFT_SCL_PIN_NUM_MAXSIZE 12U /*<! SCL pin number max size  */

/**
 * @brief I2C响应类型
 *
 */
typedef enum
{
    I2C_SOFT_RESP_ACK  = 0U,
    I2C_SOFT_RESP_NACK = 1U,
} snf_i2c_soft_resp_e;

/**
 * @brief 软件模拟I2C配置结构体, freq = 100KHz
 *
 */
typedef struct
{
    uint32_t sda_pin_num;                                    /*<! SDA pin number  */
    uint32_t scl_pin_num_list[I2C_SOFT_SCL_PIN_NUM_MAXSIZE]; /*<! SCL pin number list  */
    uint8_t  scl_count;                                      /*<! SCL pin number count  */
} snf_i2c_soft_config_t;

result_e            snf_drv_i2c_soft_init(const snf_i2c_soft_config_t *i2c_config);
void                snf_drv_i2c_soft_start(void);
void                snf_drv_i2c_soft_stop(void);
void                snf_drv_i2c_soft_ack(void);
void                snf_drv_i2c_soft_nack(void);
snf_i2c_soft_resp_e snf_drv_i2c_soft_wait4ack(void);
void                snf_drv_i2c_soft_send_byte(uint8_t tx_data);
uint8_t             snf_drv_i2c_soft_recv_byte(void);
result_e            snf_drv_i2c_soft_select_sclx(uint8_t scl_serial_num);

#endif
